package com.open.capacity.forum.feign.impl;

import com.open.capacity.common.exception.controller.ControllerException;
import com.open.capacity.common.web.Result;
import com.open.capacity.forum.feign.PointsCenterService;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;

/**
 * @author 蒋鑫
 * @version 2021/3/8
 */
@Slf4j
public class PointsCenterServiceFallback implements FallbackFactory<PointsCenterService> {
    @Override
    public PointsCenterService create(Throwable throwable) {
        log.error("积分服务异常" + throwable);
        return new PointsCenterService() {
            @Override
            public Result<Integer> findPointsByUserId(long userId) throws ControllerException {
                return Result.failed("查询失败");
            }

            @Override
            public Result change(Long userId, String pointsRuleCode, int points) throws ControllerException {
                return Result.failed("积分变动失败");
            }
        };
    }
}
